package com.itboye.ihomebank;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.itboye.ihomebank.activity.login.LoginActivity;
import com.itboye.ihomebank.activity.myzhujia.ActivityRepair;
import com.itboye.ihomebank.base.BaseFragment;
import com.itboye.ihomebank.constants.NetPublicConstant;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.util.SPUtils;
import com.itboye.ihomebank.web.WebActivity;

/**
 * 服务
 * 
 */
public class ServiceFragment extends BaseFragment implements OnClickListener {
	View v_statusbar;
	ImageView close_icon;
	TextView add_shap_title_tv;
	RelativeLayout service_weixiu, server_jiaofei, service_mensuo,service_lvxing;

	@Override
	public int initView() {
		return 0;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.service_layout, null);
	}

	@Override

	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

	}

	@Override
	public void onMyActivityCreated() {
		setStatusBarHeight(v_statusbar);
		add_shap_title_tv.setText("住家生活");
		close_icon.setVisibility(View.GONE);
	}

	@Override
	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.service_weixiu:// 住家维修
			intent = new Intent(getActivity(), ActivityRepair.class);
			startActivity(intent);
			break;
		case R.id.server_jiaofei:// 租房保险
//			if ((SPUtils.get(getActivity(), null, SPContants.USER_ID, "") + "")
//					.equals("")) {
//				startActivity(new Intent(getActivity(), LoginActivity.class));
//			} else {
//				intent = new Intent(getActivity(), WebActivity.class);
//				intent.putExtra(
//						"url",
//						NetPublicConstant.WEB_URL02
//								+ "/qianmi/elife?uid="
//								+ (SPUtils.get(getActivity(), null,
//								SPContants.USER_ID, "") + "")
//								+ "&psw="
//								+ (SPUtils.get(getActivity(), null,
//								SPContants.PASSWORD, "") + ""));
//				intent.putExtra("title", "生活缴费");
//				startActivity(intent);
//			}
			intent = new Intent(getActivity(), WebActivity.class);
			intent.putExtra("url", "http://dx.bankbaoxian.com/shortX/#/shortXZJ");
			//intent.putExtra("url", NetPublicConstant.WEB_URL02+"/vip/travel");
			intent.putExtra("title", "租房保险");
			startActivity(intent);
			break;
		case R.id.service_mensuo:// 智能门锁
			if ((SPUtils.get(getActivity(), null, SPContants.USER_ID, "") + "")
					.equals("")) {
				startActivity(new Intent(getActivity(), LoginActivity.class));
			} else {
				MainActivity.onSetFragment().setTabSelection(2);
			}
			break;
		case R.id.service_lvxing:// 签约旅行
			intent = new Intent(getActivity(), WebActivity.class);
			intent.putExtra("url", "http://hzzhongrui.travel.bbcmart.com/");
			//intent.putExtra("url", NetPublicConstant.WEB_URL02+"/vip/travel");
			intent.putExtra("title", "签约旅行");
			startActivity(intent);
			break;
		default:
			break;
		}

	}
}
